package com.cyx.demo1_zhs.controller;

import com.cyx.demo1_zhs.info.EmpInfo;
import com.cyx.demo1_zhs.service.IEmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/emp")
public class EmpController {

    @Autowired
    private IEmpService empService;

    @PostMapping("/add")
    public Boolean add(@RequestBody EmpInfo empInfo) {
       return empService.add(empInfo) == 1;
    }

    @PostMapping("/update")
    public Boolean update(@RequestBody EmpInfo empInfo) {
        return empService.update(empInfo) == 1;
    }

    @PostMapping("/delete")
    public Boolean delete(Integer id) {
        return empService.delete(id) == 1;
    }

    @PostMapping("/list")
    public List<EmpInfo> list() {
        return empService.list();
    }
}
